Skip to content

Conversation

@schacon
Copy link
Member

@schacon schacon commented Dec 22, 2025

This is an update to the but base check command. Previously, --json was a no-op, this actually implements it. It also previously showed recent commits rather than upstream commits. Finally, I updated the style to match the simpler, ansi colored style preferred by the rest of the commands, rather than the emoji laden on this command used.

CleanShot 2025-12-22 at 20 47 51@2x

If --json is specified, it now works properly:

CleanShot 2025-12-22 at 20 48 35@2x

Copilot AI review requested due to automatic review settings December 22, 2025 19:51
@vercel
Copy link

vercel bot commented Dec 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
gitbutler-web Ignored Ignored Preview Dec 24, 2025 8:43am

@github-actions github-actions bot added the rust Pull requests that update Rust code label Dec 22, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the but base check command by implementing proper JSON output support (previously a no-op), correcting the display to show upstream commits instead of recent commits, and updating the output styling to use simpler ANSI colors instead of emojis.

Key Changes:

  • Implemented functional --json flag with structured output including base branch info, upstream commits, and branch statuses
  • Fixed commit display to show upstream_commits rather than recent_commits
  • Modernized human-readable output with ANSI color styling (dimmed, colored status indicators) replacing emoji-heavy format

Copy link
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is just one comment from me, and maybe the request for a test as I don't think there is one yet. Pinning the output now to something you like will help to keep it that way later once the command is 'modernised'.

Comment on lines 13 to 16
/// JSON output for `but base check`
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct BaseCheckOutput {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these would be better when placed in a json module (I think it's also done in but status).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Byron split this into base/mod.rs and base/json.rs

Provide a machine-readable JSON representation of the `but base check` command so callers can programmatically consume base branch info, upstream commits and branch mergeability status. Introduce serializable structs (BaseCheckOutput, BaseBranchInfo, UpstreamInfo, UpstreamCommit, BranchStatusInfo), fetch the data before deciding output mode, and serialize the gathered data (base branch details, upstream commit list and count, branch statuses, up_to_date and worktree conflict flags). The human-readable output path is preserved.
Fix the JSON output for the "but base check" command to report only actual upstream commits. The code previously used recent_commits (which lists recent commits regardless of whether they're new upstream commits), causing the reported count to mismatch the listed commits. Switched to upstream_commits so the commits array matches the behind count and reflects only new upstream commits.
Human-readable output for the "Upstream commits" section incorrectly used recent_commits, causing it to show recent commits instead of actual upstream commits. Change the code to use upstream_commits for the human output so both JSON and human-readable views consistently show only true upstream commits.
Replace emoji-based output with ANSI colored text for clearer, more
professional terminal display. Base branch names are shown in cyan; the
upstream count is yellow for >0 and green for 0. Commit SHAs are yellow
with descriptions dimmed. Status indicators are now textual tags with
color: [ok] green, [integrated] blue, [conflict] red/yellow, and [empty]
dimmed. Headers are bold and labels dimmed for a cleaner visual
hierarchy. This improves readability and removes distracting emoji icons.
Move JSON serde structs into a dedicated json.rs module to separate concerns and improve organization. The JSON output structs (BaseCheckOutput, BaseBranchInfo, UpstreamInfo, UpstreamCommit, BranchStatusInfo) were moved and made pub(super) so mod.rs can access them. The old base.rs file was removed.
Copilot AI review requested due to automatic review settings December 24, 2025 08:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines +197 to +198
"❗️ There are uncommitted changes in the worktree that may conflict with
the updates. Please commit or stash them and try again."
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string literal is broken across lines with incorrect indentation. The second line has extra indentation that will be included in the output string. Consider using a single line or properly formatted multi-line string without the leading whitespace.

Suggested change
"❗️ There are uncommitted changes in the worktree that may conflict with
the updates. Please commit or stash them and try again."
"❗️ There are uncommitted changes in the worktree that may conflict with the updates. Please commit or stash them and try again."

Copilot uses AI. Check for mistakes.
Comment on lines +185 to +204
writeln!(out, "✅ Everything is up to date")?;
}
None
}
UpdatesRequired {
worktree_conflicts,
statuses,
} => {
if !worktree_conflicts.is_empty() {
if let Some(out) = out.for_human() {
writeln!(
out,
"❗️ There are uncommitted changes in the worktree that may conflict with
the updates. Please commit or stash them and try again."
)?;
}
None
} else {
if let Some(out) = out.for_human() {
writeln!(out, "🔄 Updating branches...")?;
Copy link

Copilot AI Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Update subcommand still uses emoji-based output (✅, ❗️, 🔄) while the Check subcommand has been updated to use ANSI colored text. For consistency with the PR's stated goal of preferring "simpler, ansi colored style" over "emoji laden" style, consider updating the Update subcommand's output to match the new Check subcommand style.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants